!function($){
    let $user =$('.username');
    let $poss = $('possword2');
    let $email = $('email');
    // const $spanerr = $('span');
    // const $form = $('form');
    // let $possword = $('password');
    // let $email = $('email');
    let $flag = true;

    $user.on('blur',function(){
        // console.log(88888);
        $.ajax({
            type:'post',
            url:'http://localhost/Yoho/php/regintry.php',
            data:{
                username:$user.val()
            }
        }).done(function (result) {
            if(!result){
                $('span').html('√').css('color','green');
                $flag = true;
            }else{
                $('span').html('该用户名已经存在').css('color','red');
                $flag = false;
            }
        });
    });

    $('form').on('submit',function () {
        if($user.val() == ''){
            $('span').html('用户名不能为空').css('color','red');
            $flag = false;
        }
        if(!$flag){
            return false;
        }
    });
}(jQuery)